Ext.BLANK_IMAGE_URL = '../ext/resources/images/default/s.gif';
Ext.namespace('Ccams', 'App', 'Ccams.dm');
App.appTitle = '定制化辅助生产制造系统'; // 应用系统名称
App.pageSize = 16; // 每页的记录数
WebServiceUrl = 'services/CcamsWebService';
Ext.form.Field.prototype.msgTarget = 'side';
Ext.QuickTips.init();

/*
 * 显示进度条
 */
function showProgress(msg) {
	Ext.MessageBox.show({
		msg : msg,
		width : 300,
		wait : true,
		waitConfig : {
			interval : 200
		}
	});
};

/**
 * 显示是否汉字函数
 */
function showSF(v) {
	return (v == '0' ? '是' : '<span style="color:red">否</span>');
};

function openBrWindow(theURL, winName, features) { // v2.0
	window
			.open(
					theURL,
					winName,
					'top=0, left=0, toolbar=no, menubar=no, scrollbars=no, location=no,status=yes,resizable=no  ');
}

function rmbMoney(v){
            v = (Math.round((v-0)*100))/100;
            v = (v == Math.floor(v)) ? v + ".00" : ((v*10 == Math.floor(v*10)) ? v + "0" : v);
            v = String(v);
            var ps = v.split('.');
            var whole = ps[0];
            var sub = ps[1] ? '.'+ ps[1] : '.00';
            var r = /(\d+)(\d{3})/;
            while (r.test(whole)) {
                whole = whole.replace(r, '$1' + ',' + '$2');
            }
            v = whole + sub;
            if(v.charAt(0) == '-'){
                return '-￥' + v.substr(1);
            }
            return "￥" +  v;
};
//grid enter
Ext.override(Ext.grid.RowSelectionModel, {
	onEditorKey : function(field, e) {
		// alert('go');
		var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
		var shift = e.shiftKey;
		// Ext.log('k:' + k);
		if (k == e.ENTER) {
			e.stopEvent();
			ed.completeEdit();
			if (shift) {
				newCell = g.walkCells(ed.row, ed.col - 1, -1, this.acceptsNav,
						this);
			} else {
				// alert('go');
				newCell = g.walkCells(ed.row, ed.col + 1, 1, this.acceptsNav,
						this);
			}
		} else if (k == e.TAB) {
			e.stopEvent();
			ed.completeEdit();
			if (this.moveEditorOnEnter !== false) {
				if (shift) {
					newCell = g.walkCells(ed.row - 1, ed.col, -1,
							this.acceptsNav, this);
				} else {
					// alert('go');
					newCell = g.walkCells(ed.row + 1, ed.col, 1,
							this.acceptsNav, this);
				}
			}
		} else if (k == e.ESC) {
			ed.cancelEdit();
		}
		if (newCell) {
			g.startEditing(newCell[0], newCell[1]);
		}
	}
});
var sm2 = new Ext.grid.RowSelectionModel({
	moveEditorOnEnter : true,
	singleSelect : true,
	listeners : {
		rowselect : function(sm, row, rec) {
			centerForm.getForm().loadRecord(rec);
		}
	}

}); 

Ext.override(Ext.form.ComboBox, {
//	setDisplayField : function(v){//暂时不需要
//		
//	},
    setValueField : function(v){//设置valueField的值,不设置displayField的值
    	this.hiddenField.value = v;
    }
});